1ab92dd4d23cbac911f6b24a26c574f416110d16,plugin/hotswap-agent-owb-plugin/src/main/java/org/hotswap/agent/plugin/owb/OwbPlugin.java,OwbPlugin,registerBeanArchivePath,#String#,103
Before Change
try {
resource = resourceNameToURL(archivePath);
URI uri = resource.toURI();
if (!IOUtils.isDirectoryURL(uri.toURL())) {
LOGGER.trace("Owb - unable to watch files on URL '{}' for changes (JAR file?)", archivePath);
return;
} else {
LOGGER.info("Registering archive path {}", archivePath);
watcher.addEventListener(appClassLoader, uri, new WatchEventListener() {
@Override
public void onEvent(WatchFileEvent event) {
if (event.isFile() && event.getURI().toString().endsWith(".class")) {
// check that the class is not loaded by the classloader yet (avoid duplicate reload)
String className;
try {
className = IOUtils.urlToClassName(event.getURI());
} catch (IOException e) {
LOGGER.trace("Watch event on resource '{}' skipped, probably Ok because of delete/create event sequence (compilation not finished yet).",
e, event.getURI());
return;
}
if (!ClassLoaderHelper.isClassLoaded(appClassLoader, className) || isTestEnvironment) {
// refresh weld only for new classes
LOGGER.trace("register reload command: {} ", className);
if (isBeanArchiveRegistered(appClassLoader, archivePath)) {
// TODO : Create proxy factory
scheduler.scheduleCommand(new BeanClassRefreshCommand(appClassLoader, archivePath, event), WAIT_ON_CREATE);
}
}
}
}
});
}
LOGGER.info("Registered watch for path '{}' for changes.", resource);
} catch (URISyntaxException e) {
After Change
LOGGER.info("Registering archive path {}", archivePath);
watcher.addEventListener(appClassLoader, archiveURL, new WatchEventListener() {
@Override
public void onEvent(WatchFileEvent event) {
if (event.isFile() && event.getURI().toString().endsWith(".class")) {
// check that the class is not loaded by the classloader yet (avoid duplicate reload)
String className;
try {
className = IOUtils.urlToClassName(event.getURI());
} catch (IOException e) {
LOGGER.trace("Watch event on resource '{}' skipped, probably Ok because of delete/create event sequence (compilation not finished yet).",
e, event.getURI());
return;
}
if (!ClassLoaderHelper.isClassLoaded(appClassLoader, className) || isTestEnvironment) {
// refresh weld only for new classes
LOGGER.trace("register reload command: {} ", className);
scheduler.scheduleCommand(new BeanClassRefreshCommand(appClassLoader, archivePath, event), WAIT_ON_CREATE);
}
}
}
});
LOGGER.info("Registered watch for path '{}' for changes.", resource);
} catch (Exception e) {
LOGGER.warning("registerBeanArchivePath() exception : {}", e.getMessage());